package com.student;

import com.entity.Person;
import com.entity.Course;

public class Student extends Person {
    private Course selectedCourse;

    public Student(int id, String name, String gender) {
        super(id, name, gender);
    }

    public void selectCourse(Course course) {
        this.selectedCourse = course;
        System.out.println("学生" + getName() + "选择了课程《" + course.getName() + "》");
    }

    public void dropCourse() {
        if (selectedCourse != null) {
            System.out.println("学生" + getName() + "退选了课程《" + selectedCourse.getName() + "》");
            selectedCourse = null;
        } else {
            System.out.println("学生" + getName() + "当前未选任何课程，无法退课");
        }
    }

    public void printCourseTable() {
        if (selectedCourse != null) {
            System.out.println("学生" + getName() + "的课表：");
            System.out.println("课程编号：" + selectedCourse.getId() + "，课程名称：" + selectedCourse.getName());
            System.out.println("上课地点：" + selectedCourse.getLocation() + "，上课时间：" + selectedCourse.getTime());
        } else {
            System.out.println("学生" + getName() + "当前未选任何课程");
        }
    }

    @Override
    public void printInfo() {
        super.printInfo();
        printCourseTable();
    }
}